home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-wwdenu.adb < prev    next >
Text File  |  1996-01-30  |  3KB  |  67 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUNTIME COMPONENTS                          --
  4. --                                                                          --
  5. --                      S Y S T E M . W W D _ E N U M                       --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.3 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- The GNAT library is free software; you can redistribute it and/or modify --
  14. -- it under terms of the GNU Library General Public License as published by --
  15. -- the Free Software  Foundation; either version 2, or (at your option) any --
  16. -- later version.  The GNAT library is distributed in the hope that it will --
  17. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  18. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  19. -- Library  General  Public  License for  more  details.  You  should  have --
  20. -- received  a copy of the GNU  Library  General Public License  along with --
  21. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  22. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with Unchecked_Conversion;
  27.  
  28. with System.WCh_StW; use System.WCh_StW;
  29.  
  30. package body System.WWd_Enum is
  31.  
  32.    ----------------------------
  33.    -- Wide_Width_Enumeration --
  34.    ----------------------------
  35.  
  36.    function Wide_Width_Enumeration
  37.      (Table  : Address;
  38.       Lo, Hi : Natural;
  39.       EM     : WC_Encoding_Method)
  40.       return   Natural
  41.    is
  42.       type String_Access is access String;
  43.       type Enum_Table is array (Natural) of String_Access;
  44.       type Enum_Table_Ptr is access Enum_Table;
  45.       function A_To_T is new Unchecked_Conversion (Address, Enum_Table_Ptr);
  46.  
  47.       T : constant Enum_Table_Ptr := A_To_T (Table);
  48.       W : Natural;
  49.  
  50.    begin
  51.       W := 0;
  52.  
  53.       for J in Lo .. Hi loop
  54.          declare
  55.             WS : constant Wide_String :=
  56.               String_To_Wide_String (T (J).all, EM);
  57.  
  58.          begin
  59.             W := Natural'Max (W, WS'Length);
  60.          end;
  61.       end loop;
  62.  
  63.       return W;
  64.    end Wide_Width_Enumeration;
  65.  
  66. end System.WWd_Enum;
  67.